package cn.com.czpb.client.module.video.adapter;

import android.support.v4.app.FragmentManager;

import java.util.List;

import cn.com.czpb.client.app.FragmentVPAdapter;
import cn.com.czpb.client.module.news.NewsBaseFragment;

/**
 * Created by Administrator on 2018/2/14.
 */

public class FragmentVideoAdapter extends FragmentVPAdapter<NewsBaseFragment> {
    private List<NewsBaseFragment> mFragments;
    private List<String> titles;
    public FragmentVideoAdapter(FragmentManager fm, List<NewsBaseFragment> mFragments,List<String> titles) {
        super(fm);
        this.mFragments = mFragments;
        this.titles = titles;
    }
    public FragmentVideoAdapter(FragmentManager fm) {
        super(fm);
    }
    public void setData( List<NewsBaseFragment> mFragments,List<String> titles){
        this.mFragments = mFragments;
        this.titles = titles;
    }

    @Override
    public NewsBaseFragment getItem(int position) {//必须实现
        return mFragments.get(position);
    }

    @Override
    public int getCount() {//必须实现
        return mFragments.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {//选择性实现
        if (titles != null && titles.size() > 0) {
            return titles.get(position);
        }
        return null;
    }
}
